#ifndef _ROS_robot_msgs_BatteryStatus_h
#define _ROS_robot_msgs_BatteryStatus_h

#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include "ros/msg.h"
#include "std_msgs/Header.h"

namespace robot_msgs
{

  class BatteryStatus : public ros::Msg
  {
    public:
      typedef std_msgs::Header _header_type;
      _header_type header;
      typedef int8_t _pack_quantity_type;
      _pack_quantity_type pack_quantity;
      typedef int8_t _cell_quantity_type;
      _cell_quantity_type cell_quantity;
      uint32_t cell_length;
      typedef float _cell_type;
      _cell_type st_cell;
      _cell_type * cell;
      typedef int8_t _temp_quantity_type;
      _temp_quantity_type temp_quantity;
      uint32_t temp_length;
      typedef float _temp_type;
      _temp_type st_temp;
      _temp_type * temp;
      typedef float _current_type;
      _current_type current;
      typedef float _voltage_type;
      _voltage_type voltage;
      typedef float _left_lightmod_type;
      _left_lightmod_type left_lightmod;
      typedef float _capacity_type;
      _capacity_type capacity;
      typedef int8_t _custom_type;
      _custom_type custom;
      typedef float _cycle_type;
      _cycle_type cycle;
      typedef float _design_capacity_type;
      _design_capacity_type design_capacity;

    BatteryStatus():
      header(),
      pack_quantity(0),
      cell_quantity(0),
      cell_length(0), cell(NULL),
      temp_quantity(0),
      temp_length(0), temp(NULL),
      current(0),
      voltage(0),
      left_lightmod(0),
      capacity(0),
      custom(0),
      cycle(0),
      design_capacity(0)
    {
    }

    virtual int serialize(unsigned char *outbuffer) const
    {
      int offset = 0;
      offset += this->header.serialize(outbuffer + offset);
      union {
        int8_t real;
        uint8_t base;
      } u_pack_quantity;
      u_pack_quantity.real = this->pack_quantity;
      *(outbuffer + offset + 0) = (u_pack_quantity.base >> (8 * 0)) & 0xFF;
      offset += sizeof(this->pack_quantity);
      union {
        int8_t real;
        uint8_t base;
      } u_cell_quantity;
      u_cell_quantity.real = this->cell_quantity;
      *(outbuffer + offset + 0) = (u_cell_quantity.base >> (8 * 0)) & 0xFF;
      offset += sizeof(this->cell_quantity);
      *(outbuffer + offset + 0) = (this->cell_length >> (8 * 0)) & 0xFF;
      *(outbuffer + offset + 1) = (this->cell_length >> (8 * 1)) & 0xFF;
      *(outbuffer + offset + 2) = (this->cell_length >> (8 * 2)) & 0xFF;
      *(outbuffer + offset + 3) = (this->cell_length >> (8 * 3)) & 0xFF;
      offset += sizeof(this->cell_length);
      for( uint32_t i = 0; i < cell_length; i++){
      union {
        float real;
        uint32_t base;
      } u_celli;
      u_celli.real = this->cell[i];
      *(outbuffer + offset + 0) = (u_celli.base >> (8 * 0)) & 0xFF;
      *(outbuffer + offset + 1) = (u_celli.base >> (8 * 1)) & 0xFF;
      *(outbuffer + offset + 2) = (u_celli.base >> (8 * 2)) & 0xFF;
      *(outbuffer + offset + 3) = (u_celli.base >> (8 * 3)) & 0xFF;
      offset += sizeof(this->cell[i]);
      }
      union {
        int8_t real;
        uint8_t base;
      } u_temp_quantity;
      u_temp_quantity.real = this->temp_quantity;
      *(outbuffer + offset + 0) = (u_temp_quantity.base >> (8 * 0)) & 0xFF;
      offset += sizeof(this->temp_quantity);
      *(outbuffer + offset + 0) = (this->temp_length >> (8 * 0)) & 0xFF;
      *(outbuffer + offset + 1) = (this->temp_length >> (8 * 1)) & 0xFF;
      *(outbuffer + offset + 2) = (this->temp_length >> (8 * 2)) & 0xFF;
      *(outbuffer + offset + 3) = (this->temp_length >> (8 * 3)) & 0xFF;
      offset += sizeof(this->temp_length);
      for( uint32_t i = 0; i < temp_length; i++){
      union {
        float real;
        uint32_t base;
      } u_tempi;
      u_tempi.real = this->temp[i];
      *(outbuffer + offset + 0) = (u_tempi.base >> (8 * 0)) & 0xFF;
      *(outbuffer + offset + 1) = (u_tempi.base >> (8 * 1)) & 0xFF;
      *(outbuffer + offset + 2) = (u_tempi.base >> (8 * 2)) & 0xFF;
      *(outbuffer + offset + 3) = (u_tempi.base >> (8 * 3)) & 0xFF;
      offset += sizeof(this->temp[i]);
      }
      union {
        float real;
        uint32_t base;
      } u_current;
      u_current.real = this->current;
      *(outbuffer + offset + 0) = (u_current.base >> (8 * 0)) & 0xFF;
      *(outbuffer + offset + 1) = (u_current.base >> (8 * 1)) & 0xFF;
      *(outbuffer + offset + 2) = (u_current.base >> (8 * 2)) & 0xFF;
      *(outbuffer + offset + 3) = (u_current.base >> (8 * 3)) & 0xFF;
      offset += sizeof(this->current);
      union {
        float real;
        uint32_t base;
      } u_voltage;
      u_voltage.real = this->voltage;
      *(outbuffer + offset + 0) = (u_voltage.base >> (8 * 0)) & 0xFF;
      *(outbuffer + offset + 1) = (u_voltage.base >> (8 * 1)) & 0xFF;
      *(outbuffer + offset + 2) = (u_voltage.base >> (8 * 2)) & 0xFF;
      *(outbuffer + offset + 3) = (u_voltage.base >> (8 * 3)) & 0xFF;
      offset += sizeof(this->voltage);
      union {
        float real;
        uint32_t base;
      } u_left_lightmod;
      u_left_lightmod.real = this->left_lightmod;
      *(outbuffer + offset + 0) = (u_left_lightmod.base >> (8 * 0)) & 0xFF;
      *(outbuffer + offset + 1) = (u_left_lightmod.base >> (8 * 1)) & 0xFF;
      *(outbuffer + offset + 2) = (u_left_lightmod.base >> (8 * 2)) & 0xFF;
      *(outbuffer + offset + 3) = (u_left_lightmod.base >> (8 * 3)) & 0xFF;
      offset += sizeof(this->left_lightmod);
      union {
        float real;
        uint32_t base;
      } u_capacity;
      u_capacity.real = this->capacity;
      *(outbuffer + offset + 0) = (u_capacity.base >> (8 * 0)) & 0xFF;
      *(outbuffer + offset + 1) = (u_capacity.base >> (8 * 1)) & 0xFF;
      *(outbuffer + offset + 2) = (u_capacity.base >> (8 * 2)) & 0xFF;
      *(outbuffer + offset + 3) = (u_capacity.base >> (8 * 3)) & 0xFF;
      offset += sizeof(this->capacity);
      union {
        int8_t real;
        uint8_t base;
      } u_custom;
      u_custom.real = this->custom;
      *(outbuffer + offset + 0) = (u_custom.base >> (8 * 0)) & 0xFF;
      offset += sizeof(this->custom);
      union {
        float real;
        uint32_t base;
      } u_cycle;
      u_cycle.real = this->cycle;
      *(outbuffer + offset + 0) = (u_cycle.base >> (8 * 0)) & 0xFF;
      *(outbuffer + offset + 1) = (u_cycle.base >> (8 * 1)) & 0xFF;
      *(outbuffer + offset + 2) = (u_cycle.base >> (8 * 2)) & 0xFF;
      *(outbuffer + offset + 3) = (u_cycle.base >> (8 * 3)) & 0xFF;
      offset += sizeof(this->cycle);
      union {
        float real;
        uint32_t base;
      } u_design_capacity;
      u_design_capacity.real = this->design_capacity;
      *(outbuffer + offset + 0) = (u_design_capacity.base >> (8 * 0)) & 0xFF;
      *(outbuffer + offset + 1) = (u_design_capacity.base >> (8 * 1)) & 0xFF;
      *(outbuffer + offset + 2) = (u_design_capacity.base >> (8 * 2)) & 0xFF;
      *(outbuffer + offset + 3) = (u_design_capacity.base >> (8 * 3)) & 0xFF;
      offset += sizeof(this->design_capacity);
      return offset;
    }

    virtual int deserialize(unsigned char *inbuffer)
    {
      int offset = 0;
      offset += this->header.deserialize(inbuffer + offset);
      union {
        int8_t real;
        uint8_t base;
      } u_pack_quantity;
      u_pack_quantity.base = 0;
      u_pack_quantity.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
      this->pack_quantity = u_pack_quantity.real;
      offset += sizeof(this->pack_quantity);
      union {
        int8_t real;
        uint8_t base;
      } u_cell_quantity;
      u_cell_quantity.base = 0;
      u_cell_quantity.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
      this->cell_quantity = u_cell_quantity.real;
      offset += sizeof(this->cell_quantity);
      uint32_t cell_lengthT = ((uint32_t) (*(inbuffer + offset))); 
      cell_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
      cell_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
      cell_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
      offset += sizeof(this->cell_length);
      if(cell_lengthT > cell_length)
        this->cell = (float*)realloc(this->cell, cell_lengthT * sizeof(float));
      cell_length = cell_lengthT;
      for( uint32_t i = 0; i < cell_length; i++){
      union {
        float real;
        uint32_t base;
      } u_st_cell;
      u_st_cell.base = 0;
      u_st_cell.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
      u_st_cell.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
      u_st_cell.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
      u_st_cell.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
      this->st_cell = u_st_cell.real;
      offset += sizeof(this->st_cell);
        memcpy( &(this->cell[i]), &(this->st_cell), sizeof(float));
      }
      union {
        int8_t real;
        uint8_t base;
      } u_temp_quantity;
      u_temp_quantity.base = 0;
      u_temp_quantity.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
      this->temp_quantity = u_temp_quantity.real;
      offset += sizeof(this->temp_quantity);
      uint32_t temp_lengthT = ((uint32_t) (*(inbuffer + offset))); 
      temp_lengthT |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1); 
      temp_lengthT |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2); 
      temp_lengthT |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3); 
      offset += sizeof(this->temp_length);
      if(temp_lengthT > temp_length)
        this->temp = (float*)realloc(this->temp, temp_lengthT * sizeof(float));
      temp_length = temp_lengthT;
      for( uint32_t i = 0; i < temp_length; i++){
      union {
        float real;
        uint32_t base;
      } u_st_temp;
      u_st_temp.base = 0;
      u_st_temp.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
      u_st_temp.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
      u_st_temp.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
      u_st_temp.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
      this->st_temp = u_st_temp.real;
      offset += sizeof(this->st_temp);
        memcpy( &(this->temp[i]), &(this->st_temp), sizeof(float));
      }
      union {
        float real;
        uint32_t base;
      } u_current;
      u_current.base = 0;
      u_current.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
      u_current.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
      u_current.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
      u_current.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
      this->current = u_current.real;
      offset += sizeof(this->current);
      union {
        float real;
        uint32_t base;
      } u_voltage;
      u_voltage.base = 0;
      u_voltage.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
      u_voltage.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
      u_voltage.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
      u_voltage.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
      this->voltage = u_voltage.real;
      offset += sizeof(this->voltage);
      union {
        float real;
        uint32_t base;
      } u_left_lightmod;
      u_left_lightmod.base = 0;
      u_left_lightmod.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
      u_left_lightmod.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
      u_left_lightmod.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
      u_left_lightmod.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
      this->left_lightmod = u_left_lightmod.real;
      offset += sizeof(this->left_lightmod);
      union {
        float real;
        uint32_t base;
      } u_capacity;
      u_capacity.base = 0;
      u_capacity.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
      u_capacity.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
      u_capacity.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
      u_capacity.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
      this->capacity = u_capacity.real;
      offset += sizeof(this->capacity);
      union {
        int8_t real;
        uint8_t base;
      } u_custom;
      u_custom.base = 0;
      u_custom.base |= ((uint8_t) (*(inbuffer + offset + 0))) << (8 * 0);
      this->custom = u_custom.real;
      offset += sizeof(this->custom);
      union {
        float real;
        uint32_t base;
      } u_cycle;
      u_cycle.base = 0;
      u_cycle.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
      u_cycle.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
      u_cycle.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
      u_cycle.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
      this->cycle = u_cycle.real;
      offset += sizeof(this->cycle);
      union {
        float real;
        uint32_t base;
      } u_design_capacity;
      u_design_capacity.base = 0;
      u_design_capacity.base |= ((uint32_t) (*(inbuffer + offset + 0))) << (8 * 0);
      u_design_capacity.base |= ((uint32_t) (*(inbuffer + offset + 1))) << (8 * 1);
      u_design_capacity.base |= ((uint32_t) (*(inbuffer + offset + 2))) << (8 * 2);
      u_design_capacity.base |= ((uint32_t) (*(inbuffer + offset + 3))) << (8 * 3);
      this->design_capacity = u_design_capacity.real;
      offset += sizeof(this->design_capacity);
     return offset;
    }

    const char * getType(){ return "robot_msgs/BatteryStatus"; };
    const char * getMD5(){ return "80dea0431d41e380fd14ab22355c418b"; };

  };

}
#endif